<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1"><title id="dw20941">MOVE</title><body><p id="sql_command_desc">Positions a cursor.</p><section id="section2"><title>Synopsis</title><codeblock id="sql_command_synopsis">MOVE [ <varname>forward_direction</varname> [ FROM | IN ] ] <varname>cursor_name</varname></codeblock><p>where <varname>forward_direction</varname> can be empty or one of:</p><codeblock>    NEXT
    FIRST
    LAST
    ABSOLUTE <varname>count</varname>
    RELATIVE <varname>count</varname>
    <varname>count</varname>
    ALL
    FORWARD
    FORWARD <varname>count</varname>
    FORWARD ALL</codeblock></section><section id="section3"><title>Description</title><p><codeph>MOVE</codeph> repositions a cursor
        without retrieving any data. <codeph>MOVE</codeph> works exactly like the <codeph><xref
            href="FETCH.xml#topic1" type="topic" format="dita"/></codeph> command, except it only
        positions the cursor and does not return rows. </p>

       <note>You cannot <codeph>MOVE</codeph> a <codeph>PARALLEL RETRIEVE CURSOR</codeph>.</note>
       <p>It is not possible to move a
        cursor position backwards in Greenplum Database, since scrollable cursors are not supported.
        You can only move a cursor forward in position using <codeph>MOVE</codeph>.</p><sectiondiv
        id="section4"><b>Outputs</b><p>On successful completion, a <codeph>MOVE</codeph> command
          returns a command tag of the form</p><codeblock>MOVE <varname>count</varname></codeblock><p>The count
          is the number of rows that a <codeph>FETCH</codeph> command with the same parameters would
          have returned (possibly zero). </p></sectiondiv></section><section id="section5"><title>Parameters</title><parml><plentry><pt><varname>forward_direction</varname></pt><pd>The parameters for the <codeph>MOVE</codeph> command are identical to those of the
              <codeph>FETCH</codeph> command; refer to <codeph><xref href="FETCH.xml#topic1"
              /></codeph>  for details on syntax and usage.</pd></plentry><plentry><pt><varname>cursor_name</varname></pt><pd>The name of an open cursor.</pd></plentry></parml></section><section id="section6"><title>Examples</title><p>-- Start the transaction:</p><codeblock>BEGIN;</codeblock><p>-- Set up a cursor:</p><codeblock>DECLARE mycursor CURSOR FOR SELECT * FROM films;</codeblock><p>-- Move forward 5 rows in the cursor <codeph>mycursor</codeph>:</p><codeblock>MOVE FORWARD 5 IN mycursor;
MOVE 5</codeblock><p>--Fetch the next row after that (row 6):</p><codeblock>FETCH 1 FROM mycursor;
 code  | title  | did | date_prod  |  kind  |  len
-------+--------+-----+------------+--------+-------
 P_303 | 48 Hrs | 103 | 1982-10-22 | Action | 01:37
(1 row)</codeblock><p>-- Close the cursor and end the transaction:</p><codeblock>CLOSE mycursor;
COMMIT;</codeblock></section><section id="section7"><title>Compatibility</title><p>There is no <codeph>MOVE</codeph> statement in the SQL standard.</p></section><section id="section8"><title>See Also</title><p><codeph><xref href="DECLARE.xml#topic1" type="topic" format="dita"/></codeph>, <codeph><xref
            href="FETCH.xml#topic1" type="topic" format="dita"/></codeph>, <codeph><xref
            href="CLOSE.xml#topic1" type="topic" format="dita"/></codeph></p></section></body></topic>
